package com.banmoon.datastructure.BinarySearchTree;

public class Test {

    public static void main(String[] args) {
        int[] values = {7, 3, 10, 12, 5, 1, 9};
        BinarySearchTree binarySearchTree = BinarySearchTree.generate(values);
        // 中序遍历
        binarySearchTree.show();
        // 查找节点
        Node node12 = binarySearchTree.search(12);
        Node node23 = binarySearchTree.search(23);
        System.out.println(System.lineSeparator() + node12);
        System.out.println(node23);
        // 删除节点
        System.out.println(System.lineSeparator() + "======== 分割线 ========");
        binarySearchTree.delete(12);
        binarySearchTree.show();
        System.out.println(System.lineSeparator() + "======== 分割线 ========");
        binarySearchTree.delete(7);
        binarySearchTree.show();
        System.out.println(System.lineSeparator() + "======== 分割线 ========");
        binarySearchTree.delete(9);
        binarySearchTree.show();
        System.out.println(System.lineSeparator() + "======== 分割线 ========");
        binarySearchTree.delete(10);
        binarySearchTree.show();
        System.out.println();
    }
}
